﻿// Admin.aspx
var deletedPage;
function deletepage(page_Id) {
    deletedPage=page_Id;
    var data='page_id='+page_Id;
    var myAjax = new Ajax.Request(
        '../handlers/insertPage.ashx?status=page&mode=delete',
        {method: 'post', parameters: data, onComplete: pageDeleted}
    );
}

function pageDeleted(originalRequest) {
    Element.remove('page-'+deletedPage);
    deletedPage='';
}

//To load Articles related to page
function loadArticles(page_Id) {
    var data='page_id='+page_Id;
    var myAjax = new Ajax.Request(
        '../handlers/insertPage.ashx?status=article&mode=load',
        {method: 'post', parameters: data, onComplete: articlesLoaded}
    );
}

function articlesLoaded(originalRequest) {
    $('articlesContent').innerHTML=originalRequest.responseText;
}

//To delete article
var deletedArticle;
function deleteArticle(article_id) {
    deletedArticle=article_id;
    var data='article_Id='+article_id;
    var myAjax = new Ajax.Request(
        '../handlers/insertPage.ashx?status=article&mode=delete',
        {method: 'post', parameters: data, onComplete: articleDeleted}
    );
}

function articleDeleted(originalRequest) {
    Element.remove('article-'+deletedArticle);
    deletedArticle='';
}

// To Edit Article
function editArticle(article_Id)
{
    window.location.href='article.aspx?id='+article_Id;
}

// To Edit Page
function editpage(page_Id)
{
    window.location.href='page.aspx?id='+page_Id;
}

// Article.aspx